package com.gy.studyonlineapp.fragment;

import androidx.lifecycle.ViewModelProvider;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;

import com.gy.studyonlineapp.ViewModel.ViewModelMine;
import com.gy.studyonlineapp.R;
import com.gy.studyonlineapp.activity.AboutActivity;
import com.gy.studyonlineapp.activity.HistoryActivity;
import com.gy.studyonlineapp.activity.LoginActivity;
import com.gy.studyonlineapp.activity.ModifyPasswordActivity;
import com.gy.studyonlineapp.activity.MyCollectActivity;
import com.gy.studyonlineapp.activity.MyErrorActivity;

public class FragmentMine extends Fragment {

    private ViewModelMine mViewModel;

    public static FragmentMine newInstance() {
        return new FragmentMine();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_mine,container,false);
        ImageView imageView5 = view.findViewById(R.id.imageView5);
        ImageView imageView2 = view.findViewById(R.id.imageView2);
        ImageView imageView = view.findViewById(R.id.imageView);
        ImageView imageView3 = view.findViewById(R.id.imageView3);
        ImageView imageView4 = view.findViewById(R.id.imageView4);
        Button button7 = view.findViewById(R.id.button7);
        Button button8 = view.findViewById(R.id.button8);

        button7.setOnClickListener(new View.OnClickListener() {
            @Override //跳转修改密码界面
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), ModifyPasswordActivity.class);
                startActivity(intent);
            }
        });

        button8.setOnClickListener(new View.OnClickListener() {
            @Override //注销用户跳转到登录界面
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), LoginActivity.class);
                startActivity(intent);
            }
        });

        imageView4.setOnClickListener(new View.OnClickListener() {
            @Override //跳转历史记录界面
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), HistoryActivity.class);
                startActivity(intent);
            }
        });

        imageView3.setOnClickListener(new View.OnClickListener() {
            @Override //跳转我的错题界面
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), MyErrorActivity.class);
                startActivity(intent);
            }
        });

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override //跳转我的收藏界面
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), MyCollectActivity.class);
                startActivity(intent);
            }
        });

        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override //跳转关于APP详情界面
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(),AboutActivity.class);
                startActivity(intent);
            }
        });
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mViewModel = new ViewModelProvider(this).get(ViewModelMine.class);
        // TODO: Use the ViewModel
    }

}